package com.sh.caryr.erp.controller;

import com.sh.caryr.erp.entity.enums.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import static com.sh.caryr.erp.util.ERPConstants.NEW_OBJECT_ID;

@Controller
public class PageNavigateController {

    /******************************* Dashboard **************/
    @RequestMapping(value = "/dashboard", method = RequestMethod.GET)
    public String dashboard() {
        return "basis/dashboard";
    }

    /******************************* User **************/
    @RequestMapping(value = "/userLogin", method = RequestMethod.GET)
    public String userLogin() {
        return "user/userLogin";
    }

    @RequestMapping(value = "/user", method = RequestMethod.GET)
    public String user() {
        return "user/user";
    }

    @RequestMapping(value = "/userRole", method = RequestMethod.GET)
    public String userRoleNew() {
        return "user/userRole";
    }

    /******************************* Product **************/
    @RequestMapping(value = "/product", method = RequestMethod.GET)
    public String product() {
        return "product/product";
    }

    @RequestMapping(value = "/productMapping", method = RequestMethod.GET)
    public String productMapping() {
        return "product/productMapping";
    }

    @RequestMapping(value = "/proAttribute", method = RequestMethod.GET)
    public String proAttribute() {
        return "product/attribute";
    }

    @RequestMapping(value = "/stock", method = RequestMethod.GET)
    public String sku() {
        return "product/stock";
    }

    @RequestMapping(value = "skuRecord", method = RequestMethod.GET)
    public String skuRecord(){
        return "product/skuRecord";
    }

    /******************************* Orders **************/
    @RequestMapping(value = "/orders", method = RequestMethod.GET)
    public String trades() {
        return "order/" + Page.PAGE_ORDERS.getVal();
    }

    @RequestMapping(value = "/orderDetails", method = RequestMethod.GET)
    public String tradeDetails(@RequestParam(name = "orderId") Long orderId, Model model) {
        model.addAttribute("orderId", orderId != null ? orderId : NEW_OBJECT_ID);
        return "order/" + Page.PAGE_ORDER_DETAILS.getVal();
    }

    @RequestMapping(value = "/asOrders", method = RequestMethod.GET)
    public String asOrders() {
        return "order/" + Page.PAGE_AS_ORDERS.getVal();
    }

    @RequestMapping(value = "/importTrades", method = RequestMethod.GET)
    public String importTrades() {
        return "order/importTrades";
    }

    /******************************* Setting **************/
    @RequestMapping(value = "/shop", method = RequestMethod.GET)
    public String shop() {
        return "basis/shop";
    }

    /******************************* System **************/
    @RequestMapping(value = "/error_not_found", method = RequestMethod.GET)
    public String notFound() {
        return "system/404";
    }

}
